package com.hyt.it.ogt.kq.common.gov.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;

import java.util.Arrays;

/**
 * 性别
 *
 * @author liying
 */
@Getter
public enum SexEnums {

    MAN(1, "男"),
    WOMAN(2, "女"),
    WOMAN2(0, "女"),
    ;

    private final String code;
    private final Integer type;
    private final String desc;

    SexEnums(Integer type, String desc) {
        this.code = name();
        this.type = type;
        this.desc = desc;
    }

    public static String[] allDesc() {
        return Arrays.stream(values())
                .map(SexEnums::getDesc)
                .distinct()
                .toArray(String[]::new);
    }

    public static String getTypeByDesc(String desc) {
        for (SexEnums sexEnums : values()) {
            if (sexEnums.getDesc().equals(desc)) {
                return sexEnums.getType().toString();
            }
        }
        return null;
    }
    
    public static String getDescByType(Integer type) {
        for (SexEnums sexEnums : values()) {
            if (sexEnums.getType().equals(type)) {
                return sexEnums.getDesc();
            }
        }
        return null;
    }
}
